set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CROSS_COMPILING_ROOT /usr/local/share/toolchain-openwrt-arm32/toolchain)

SET(CMAKE_C_COMPILER    /usr/local/share/toolchain-openwrt-arm32/toolchain/bin/arm-openwrt-linux-gcc)
SET(CMAKE_CXX_COMPILER  /usr/local/share/toolchain-openwrt-arm32/toolchain/bin/arm-openwrt-linux-g++)

if(NOT DEFINED CROSS_COMPILING_ROOT)
  set(CROSS_COMPILING_ROOT $ENV{CROSS_COMPILING_ROOT})
endif()

if(NOT DEFINED CROSS_COMPILING_ROOT)
  message(FATAL_ERROR "Missing CROSS_COMPILING_ROOT")
elseif(NOT IS_DIRECTORY ${CROSS_COMPILING_ROOT})
  message(FATAL_ERROR "CROSS_COMPILING_ROOT is not directory: ${CROSS_COMPILING_ROOT}")
endif()

set(CMAKE_FIND_ROOT_PATH ${CROSS_COMPILING_ROOT})

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(SYSTEM_DETAILS arm32-openwrt)
